﻿@model App.Web.ViewModels.ContactViewModel
@using App.Web.Utility;


@{
    String pageTitle = "Edit Contact";
    if(Model.ID == 0){
        pageTitle = "Add Contact";
    }
    bool _IsRegistrationMode = ViewBag.IsRegistrationMode != null && ViewBag.IsRegistrationMode ? true : false;
    //bool _CompanyName = ViewBag.CompanyName != null ? ViewBag.CompanyName : false;
    //bool _Email = ViewBag.Email != null && ViewBag.IsRegistrationMode ? true : false;
    
    String heading = pageTitle;
    if(_IsRegistrationMode){
        pageTitle = "Create Your Store.";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    ViewBag.Title = Html.GetPageTitle(pageTitle);
}
<div class="page-heading">
    <h1>@pageTitle</h1>
    
        @if (_IsRegistrationMode)
        {
            <div>Register your company in BDMarket24 and add contact/employee information.</div>
        }
        else
        {
            <div>Manage your contact/employee information of your company.</div>   
        }
    

    
</div>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

@Html.Partial("_DatePicker")

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <div class="GroupBox">
        @*<div class="GroupHeaderOverlay" style="width:90px;">@heading</div>*@

        @Html.HiddenFor(model => model.ID)

        @if (_IsRegistrationMode)
        {
            <div class="editor-label">
                Store Name
            </div>
            <div class="editor-field">
                <input type="text" value="@ViewBag.CompanyName"
                    name="CompanyName" 
                    id="CompanyName" 
                    data-val-required="Please Enter The Company Name" 
                    data-val-length-max="50" 
                    data-val-length="The First Name can be maximum 50 characters long." 
                    data-val="true" 
                    class="text-box single-line">
                
                <span class="field-validation-valid" data-valmsg-for="CompanyName" data-valmsg-replace="true"></span>
                @Html.ValidationMessage("DuplicateCompany")
            </div>
            
            <div class="editor-label">
                Email
            </div>
            <div class="editor-field">
                <input class="text-box single-line" 
                    data-val="true"
                    data-val-required="Please Enter The Email" 
                    data-val-length="The Personal Email can be maximum 100 characters long." 
                    data-val-length-max="100" 
                    data-val-regex="Please Enter a valid Email address" 
                    data-val-regex-pattern="\w+([-+.&#39;]\w+)*@@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                    id="Email" 
                    name="Email" 
                    type="text" 
                    value="@ViewBag.Email" />
                <span class="field-validation-valid" 
                    data-valmsg-for="Email" 
                    data-valmsg-replace="true"></span>
                @Html.ValidationMessage("DuplicateEmail")
            </div>
            
        }
        
        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>
        @if (!_IsRegistrationMode)
        {
        <div class="editor-label">
            @Html.LabelFor(model => model.Gender)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Gender, BindSelectList.Gender()) 
            @*@Html.EditorFor(model => model.Gender)*@
            @Html.ValidationMessageFor(model => model.Gender)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.EmailPersonal)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EmailPersonal)
            @Html.ValidationMessageFor(model => model.EmailPersonal)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.EmailOffice)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EmailOffice)
            @Html.ValidationMessageFor(model => model.EmailOffice)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.PhoneHome)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneHome)
            @Html.ValidationMessageFor(model => model.PhoneHome)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PhoneMobile)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneMobile)
            @Html.ValidationMessageFor(model => model.PhoneMobile)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PhoneOffice)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneOffice)
            @Html.ValidationMessageFor(model => model.PhoneOffice)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PreferedPhone)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.PreferedPhone, BindSelectList.PreferredPhone())
            @Html.ValidationMessageFor(model => model.PreferedPhone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address1)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address1)
            @Html.ValidationMessageFor(model => model.Address1)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address2)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address2)
            @Html.ValidationMessageFor(model => model.Address2)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DateOfBirth)
        </div>
        <div class="editor-field">
            @*<span class="datePicker">*@
            @Html.TextBoxFor(model => model.DateOfBirth, new { @class = "datepicker" })
            @Html.ValidationMessageFor(model => model.DateOfBirth)
            @*</span>*@
            @*@Html.EditorFor(model => model.DateOfBirth)
            @Html.ValidationMessageFor(model => model.DateOfBirth)*@
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ReligionID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ReligionID, BindSelectList.Religions())
            @Html.ValidationMessageFor(model => model.ReligionID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IsActive)
        </div>
        <div class="editor-field">            
            @Html.RadioButtonFor(model => model.IsActive, "true", new { id = "rdnIsActive_1" }) <label for="rdnIsActive_1">Yes</label>
            @Html.RadioButtonFor(model => model.IsActive, "false", new { id = "rdnIsActive_0" }) <label for="rdnIsActive_0">No</label>
            @*@Html.EditorFor(model => model.IsActive)*@
            @Html.ValidationMessageFor(model => model.IsActive)
        </div>

        @*<div class="editor-label">
            @Html.LabelFor(model => model.IsDeleted)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsDeleted)
            @Html.ValidationMessageFor(model => model.IsDeleted)
        </div>*@

        <div class="editor-label">
            @Html.LabelFor(model => model.FatherName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FatherName)
            @Html.ValidationMessageFor(model => model.FatherName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MotherName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.MotherName)
            @Html.ValidationMessageFor(model => model.MotherName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.HusbandName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.HusbandName)
            @Html.ValidationMessageFor(model => model.HusbandName)
        </div>

        @*<div class="editor-label">
            @Html.LabelFor(model => model.CompanyID)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CompanyID)
            @Html.ValidationMessageFor(model => model.CompanyID)
        </div>*@
            
        @Html.HiddenFor(model => model.CompanyID)
        @Html.ValidationMessageFor(model => model.CompanyID)
        @Html.HiddenFor(model => model.IsDeleted)
        @Html.ValidationMessageFor(model => model.IsDeleted)      
        
        }    
        @if (_IsRegistrationMode)
        {
        <div>
            <div class="GroupHeaderOverlay">Account Information</div>
            <div class="editor-label">
                @Html.LabelFor(model => model.User.UserName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.User.UserName)
                @Html.ValidationMessageFor(model => model.User.UserName)
                @Html.ValidationMessage("DuplicateUser")
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.User.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(model => model.User.Password)
                @Html.ValidationMessageFor(model => model.User.Password)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.User.ConfirmPassword)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(model => model.User.ConfirmPassword)
                @Html.ValidationMessageFor(model => model.User.ConfirmPassword)
            </div>
            @Html.HiddenFor(model => model.User.IsActive)
            @Html.HiddenFor(model => model.User.GroupID)
        </div>
        }
        <div>

            @*Example taken from: http://mvc3captcha.codeplex.com/*@

            @Html.ValidationSummary(true)
            <div class="editor-label">
                @Html.Partial("_Captcha", new Uco.Models.Captcha())
            </div>
                
            <div class="editor-field">                
                @Html.Partial("_InvisibleCaptcha", new Uco.Models.InvisibleCaptcha())
            </div>

            <input type="submit" value="Save" />  
            @if (ViewBag.IsRegistrationMode == null)
            {
                @Html.PrivateLink("Back to List", "List", "Contact")
            }            
        </div>

    </div>
}


